<?php
ob_start();
session_start();

require "constants.php";

$req = $_GET["__req"];
$pos = strpos($_GET["__req"], "/");

if(isset($req) && $pos>0){
	$req = substr($req, 0, $pos);
}elseif(!isset($req)){
	$req = "index";
}

$__content = getview($req);
include "layout.php";

function getview($view){
	$path = "views/$view.php";
	if(!file_exists($path)){
		$path = "views/index.php";
	}
	$prev = ob_get_contents();
	include $path;
	$ret = ob_get_contents();
	echo "RETURNED:<br />\n$ret";
	ob_clean();
	return trim($ret);
}

?>